﻿using RabbitMQ.GNClient;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace GN.Pay.Core.Tasks.Queue
{
    /// <summary>
    /// 队列管理
    /// </summary>
    public interface IQueueManager : Abp.Dependency.ISingletonDependency
    {
        /// <summary>
        /// 获取生产队列
        /// </summary>
        /// <param name="name">名称</param>
        /// <returns></returns>
        IProduceQueue GetProduceQueue(string name);

        /// <summary>
        /// 获取生产队列
        /// </summary>
        /// <param name="cacheType">类型</param>
        /// <returns></returns>
        IProduceQueue GetProduceQueue(QueueType queueType);

        /// <summary>
        /// 发布消息
        /// </summary>
        /// <param name="queueType">类型</param>
        /// <param name="message">消息</param>
        /// <param name="delayConsumer">过期</param>
        void Publish(QueueType queueType, ObjectMessage message, TimeSpan? delayConsumer = null);

        /// <summary>
        /// 异步发布消息
        /// </summary>
        /// <param name="queueType">类型</param>
        /// <param name="message">消息</param>
        /// <param name="delayConsumer">过期</param>
        Task PublishAsync(QueueType queueType, ObjectMessage message, TimeSpan? delayConsumer = null);

        /// <summary>
        /// 发布消息
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="message">消息</param>
        /// <param name="delayConsumer">过期</param>
        void Publish(string name, ObjectMessage message, TimeSpan? delayConsumer = null);

        /// <summary>
        /// 异步发布消息
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="message">消息</param>
        /// <param name="delayConsumer">过期</param>
        Task PublishAsync(string name, ObjectMessage message, TimeSpan? delayConsumer = null);
    }

    /// <summary>
    /// 队列类型
    /// </summary>
    public enum QueueType
    {
        /// <summary>
        /// 通道付款通知
        /// </summary>
        ChannelPayNotify,

        /// <summary>
        /// 通道退款通知
        /// </summary>
        ChannelRefundNotify,

        /// <summary>
        /// 通道转账通知
        /// </summary>
        ChannelTransfersNotify,

        /// <summary>
        /// 通知
        /// </summary>
        ClientHttpNotify,

        /// <summary>
        /// 退款申请
        /// </summary>
        ClientRefundApply,

        /// <summary>
        /// 转账申请
        /// </summary>
        ClientTransfersApply,

        /// <summary>
        /// 客户端付款成功
        /// </summary>
        ClientPaySuccessWebNotify,

        /// <summary>
        /// 队列重置
        /// </summary>
        QueueReset,

        /// <summary>
        /// 付款申请过期
        /// </summary>
        PayApplyExpire,
    }
}
